import { constantRoutes, asyncRoutes } from '@/router/index'
const state = {
    routes: constantRoutes
}
const mutations = {
    SET_ROUTES(state, payload) {
        state.routes = [...constantRoutes, ...payload]
    }
}

const actions = {
    settouter(context, menus) {
        let newrouter = []
        menus.forEach(item => {
            let res = asyncRoutes.filter(subitem => {
                if (subitem.path == '/' + item) {
                    return true
                }
                return false
            })
            newrouter.push(...res)
        })
        context.commit('SET_ROUTES', newrouter)
        return newrouter
    }
}
export default {
    namespaced: true,
    state,
    mutations,
    actions
}